import { NIcon, NTooltip } from 'naive-ui';
import { h } from 'vue';

export default () => {
    // 渲染图标
    const renderIcon = icon => {
        return () => h(NIcon, null, { default: () => h(icon) });
    };
    // 渲染带tooltip的图标
    const renderTooltipIcon = (text, icon, props, event) => {
        return h(
            NTooltip,
            {
                placement: 'bottom'
            },
            {
                trigger: () =>
                    h(
                        NIcon,
                        {
                            size: 20,
                            ...props,
                            ...event
                        },
                        { default: () => h(icon) }
                    ),
                default: () => [text]
            }
        );
    };
    return {
        renderIcon,
        renderTooltipIcon
    };
};
